package com.arouter.demo.minemodule.viewmodel;

import android.app.Activity;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.launcher.ARouter;
import com.arouter.demo.baselib.router.RouterPath;
import com.arouter.demo.baselib.router.service.HomeService;
import com.arouter.demo.baselib.router.service.MineService;
import com.arouter.demo.baselib.router.service.SearchService;
import com.arouter.demo.minemodule.R;
import com.arouter.demo.minemodule.service.SingleService;

/**
 * desc:
 * 2018-05-30 14:55
 */
public class MineVm {

    @Autowired(name = RouterPath.HOME_SERVICE)
    HomeService homeService;

    @Autowired(name = RouterPath.SEARCH_SERVICE)
    SearchService searchService;

    public MineVm() {
        ARouter.getInstance().inject(this);
    }


    public void onClickService(View v) {
        int viewId = v.getId();

        if (viewId == R.id.btn_by_name) {
            MineService mineService = (MineService) ARouter
                    .getInstance()
                    .build(RouterPath.MINE_SERVICE)
                    .navigation();

            mineService.sayHello("mike");
            return;
        }

        if (viewId == R.id.btn_by_type) {
            MineService mineService = ARouter
                    .getInstance()
                    .navigation(MineService.class);

            mineService.sayHello("mike");
            return;
        }
        if (viewId == R.id.btn_single_class) {
            SingleService singleService = ARouter.getInstance().navigation(SingleService.class);
            singleService.sayHello("mike");

            return;
        }

        if (viewId == R.id.btn_service_fail) {
            // 服务调用失败
            ARouter.getInstance().navigation(Activity.class);

        }
    }


    public void onClickModule(View v) {
        int viewId = v.getId();
        if (viewId == R.id.btn_jump_home) {
            homeService.jumpHomeActivity("xiaofeng", 30);
            return;

        }

        if (viewId == R.id.btn_jump_search) {
            searchService.jumpTestUriFirst();
        }
    }


}
